Skip to content

Comments

feat: add AWS CLI and psql modules#216

Open
itai-sagi wants to merge 1 commit intortk-ai:masterfrom
itai-sagi:feat/aws-psql-support
Open

feat: add AWS CLI and psql modules#216
itai-sagi wants to merge 1 commit intortk-ai:masterfrom
itai-sagi:feat/aws-psql-support

Conversation

@itai-sagi
Copy link

Summary

  • rtk aws: Specialized filters for 8 high-frequency AWS CLI commands (STS identity, S3 ls, EC2 describe-instances, ECS list/describe-services, RDS describe-db-instances, CloudFormation list/describe-stacks). Generic fallback forces --output json and compresses via json_cmd::filter_json_string() at depth 4. Achieves 60%+ token savings on verbose AWS table/text output.
  • rtk psql: Detects psql table format (strips ----+---- borders, (N rows) footer, column padding → tab-separated) and expanded format (-[ RECORD N ]- blocks → [N] key=val one-liners). Passthrough for COPY/SET/notices. Overflow limits: 30 table rows, 20 expanded records.
  • Hook rewrite patterns added for both aws and psql in distributable and dev hooks.

Test plan

  • 32 new inline tests (16 aws_cmd + 16 psql_cmd) all passing
  • Full test suite: 428 tests pass, 0 failures
  • cargo fmt --all clean
  • cargo clippy --all-targets — no new warnings
  • Manual test with real AWS CLI (if configured): rtk aws sts get-caller-identity
  • Manual test with real psql (if available): rtk psql -c "SELECT 1" mydb

🤖 Generated with Claude Code

@pszymkowiak
Copy link
Collaborator

Thanks for adding AWS CLI and psql support — great additions to RTK's ecosystem! Tests pass (428/428), build is clean, and existing commands are unaffected. Here are some items to address
before merge:

Critical

  1. Revert commit polluting the PR: There's a revert commit that adds noise to the diff. Please clean up the git history (interactive rebase) so only AWS/psql changes are included.
  2. run_generic --output injection: The --output json flag is injected into all AWS commands via run_generic, but not all AWS subcommands support --output. This could break commands like
    aws s3 cp or aws s3 sync. Consider only injecting --output json for commands that support structured output (describe, list, get, etc.), or catch the error and fallback to raw execution.
  3. psql tracking on failed commands: Token savings are recorded even when the psql command fails (non-zero exit code). Tracking should only happen on successful executions to avoid
    skewing metrics.

Improvements

  1. Duplicate lazy_static! blocks: Several identical regex patterns are defined in multiple lazy_static! blocks across both modules. Factor them into shared constants or a single block.
  2. Test fixtures should use real command output: Per project guidelines (see CLAUDE.md > Testing Strategy), tests should use include_str!("../tests/fixtures/...") with real command
    output, not synthetic/hardcoded strings. This ensures filters work against actual CLI output formats.
  3. Token savings threshold too low: Tests assert ≥30% savings, but RTK's project standard is ≥60%. Please raise the threshold or justify why these specific filters have lower savings
    expectations.

Minor

  • Consider adding snapshot tests (assert_snapshot!) for output format validation
  • AWS module is +845 lines — could some shared patterns (JSON flattening, table formatting) be extracted to utils.rs?

Overall solid work, looking forward to the next iteration! 🔧

@itai-sagi itai-sagi force-pushed the feat/aws-psql-support branch 2 times, most recently from 1071ae8 to 9ec3583 Compare February 22, 2026 07:36
AWS CLI (rtk aws):
- Specialized filters for sts, s3 ls, ec2, ecs, rds, cloudformation
- Generic fallback injects --output json for structured ops only
  (describe-*, list-*, get-*); mutating ops (s3 cp, deploy) pass through
- join_with_overflow() and truncate_iso_date() helpers in utils.rs

psql (rtk psql):
- Table format: strips separators/padding, outputs tab-separated
- Expanded format: compresses -[ RECORD N ]- blocks to key=val one-liners
- Passthrough for COPY results, notices, and non-table output
- 40%+ savings (table), 60%+ savings (expanded display)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@itai-sagi itai-sagi force-pushed the feat/aws-psql-support branch from 9ec3583 to dc72be6 Compare February 22, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants